//检索
function searchs(){
    top.jzts();
    $("#form").submit();
}

//查看详情
function detail(id) {
    top.jzts();
    var diag = new top.Dialog();
    diag.Drag = true;
    diag.Title = "查看详情";
    diag.URL = path + '/admin/menuOneLevelConfig/detailPage?id='+ id;
    diag.Width = 1050;
    diag.Height = 550;
    diag.CancelEvent = function(){ //关闭事件
        diag.close();
    };
    diag.show();
}

//上下架
function onOrOff(id, state, msg, currentPage) {
    var warning = "下架后将不可在该一级类别下继续创建新的二级类别！";
    var remind = "您确定要" + msg + "吗?";
    if (state == 1) { //想要下架
        remind = warning + "<br/>" + remind;
    }
    bootbox.confirm(remind, function(result) {
        if(result) {
            top.jzts();
            var url = path +'/admin/menuOneLevelConfig/onOrOff?id=' + id + "&state=" + state;
            $.get(url,function(data){
                top.hangge();
                bootbox.dialog({
                    message: "<span class='bigger-110'>" + data.msg + "</span>",
                    buttons: {
                        "button":{
                            "label":"确定",
                            "className":"btn-sm btn-success",
                            "callback": function() {
                                nextPage(currentPage);
                            }
                        }
                    }
                });
            });
        };
    });
}

//新增
function add(currentPage){
    top.jzts();
    var diag = new top.Dialog();
    diag.Drag = true;
    diag.Title ="新增";
    diag.URL = path + '/admin/menuOneLevelConfig/addPage';
    diag.Width = 1050;
    diag.Height = 580;
    diag.CancelEvent = function(){//关闭事件
        if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
            if(currentPage == '0'){
                top.jzts();
                setTimeout("self.location=self.location",100);
            }else{
                nextPage(currentPage);
            }
        }
        diag.close();
    };
    diag.show();
}

//编辑
function edit(id, currentPage){
    top.jzts();
    var diag = new top.Dialog();
    diag.Drag = true;
    diag.Title ="编辑";
    diag.URL = path + '/admin/menuOneLevelConfig/editPage?id=' + id;
    diag.Width = 1050;
    diag.Height = 580;
    diag.CancelEvent = function(){//关闭事件
        if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
            if(currentPage == '0'){
                top.jzts();
                setTimeout("self.location=self.location",100);
            }else{
                nextPage(currentPage);
            }
        }
        diag.close();
    };
    diag.show();
}

//创建二级
function createTwo(state, parentId, currentPage){
    if (state == 1) { //上架状态可以创建二级
        createTwoTrue(parentId, currentPage);
    } else { //下架状态不可以创建二级
        bootbox.alert({
            message: '必须先上架该一级类别，方可创建对应二级类别！',
            buttons: {
                ok: {
                    label: '我知道了'
                }
            }
        });
    }
}

//确定创建二级
function createTwoTrue(parentId, currentPage){
    top.jzts();
    var diag = new top.Dialog();
    diag.Drag = true;
    diag.Title ="编辑";
    diag.URL = path + '/admin/menuTwoLevelConfig/addPage?parentId=' + parentId;
    diag.Width = 1050;
    diag.Height = 580;
    diag.CancelEvent = function(){//关闭事件
        if(diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none'){
            if(currentPage == '0'){
                top.jzts();
                setTimeout("self.location=self.location",100);
            }else{
                nextPage(currentPage);
            }
        }
        diag.close();
    };
    diag.show();
}
